%get sparse id for each sperate model

addpath(genpath(pwd))
init;

genNameList;

load data_base

model_name = './result/fs_knn_feat159_on_ZO.mat';
load(model_name);


%these sel_id only for recommend_matrix
sel_id = my_model.sel_id;


recommend_feat_dim = size(data_base{1}.recommend_matrix,2);

static_id = sel_id(sel_id>recommend_feat_dim);
dynamic_id = sel_id(sel_id<=recommend_feat_dim);

bo = ones( 1,recommend_feat_dim);

bo(dynamic_id) = 0;

rest_id = find(bo==1);

rest_id = rest_id(randperm(length(rest_id)));

dynamic_id = [dynamic_id rest_id];




%%

score_id = 2;

feat_id = [1 5 9];

for base_id = 1:length(data_base )
    if score_id==1
        recommen_score{base_id} = data_base{base_id}.Fmatrix;
    elseif score_id==2
        recommen_score{base_id} = 2 * max(data_base{base_id}.ZeroOne-.5,0);
    end
end

    
    for method_id = [ 7 1]
        for num_dim_use = 30:15:240
            
            sel_id_in_loop =[dynamic_id(1:num_dim_use) static_id];

            for base_id = 1:length(data_base )

                temp = data_base{base_id}.recommend_matrix(:,dynamic_id(1:num_dim_use));

                for k = feat_id
                    if(k>=2 && k<=11 )
                        temp = [temp  data_base{base_id}.global_feat{k-1}];
                    end
                end

                recommen_feat{base_id} = temp;
            end


            my_model = train_method{ method_id }( recommen_feat{1},recommen_score{1});                        


            clear vali
            for i = 1:length( data_base )
                vali{i} = validateModel(       recommen_feat{i},...
                                               recommen_score{i}, ...
                                               my_model, ...
                                               predict_method{method_id});

            end

            vali_name = [ './vali_result/vali_exp_sel_' ...
                num2str(num_dim_use) '_' ...
                method_name{method_id} '_feat' ];
            for k = feat_id
                vali_name = [vali_name num2str( k ) ];
            end
            vali_name = [vali_name '_on_' ...
                        score_name{score_id} '.mat'];        

            get_act_score;        
        end    
    end
